package com.wuhongyu.controller;

import java.util.List;

import com.wuhongyu.entity.Message;
import com.wuhongyu.mapper.MessageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wuhongyu.entity.Count;
import com.wuhongyu.service.MessageService;

@Controller
public class MessageController {

	//妈的 竟然给我指令重排序.....
	@Autowired
	private volatile MessageService messageService;
	@Autowired
	private MessageMapper messageMapper;

	@RequestMapping("/hello")
	public String hello(String url) {
		messageService.grab(url,1);
		return "view";
	}

	@RequestMapping("/count")
	@ResponseBody
	public List<Count> count(Integer userId){
		userId = 1;
		List<Count> count = messageService.count(userId);
		return count;
	}

	@RequestMapping("/view")
	public String view(){
		return "view";
	}

	@RequestMapping("/insert")
	@ResponseBody
	public String insert(){
		Message message = new Message();
		message.setPost("111111");
		message.setUserid(1);
		messageMapper.insert(message);
		return "1111";
	}
}
